/*
 * Copyright (c)  2015~2020, xforceplus
 * All rights reserved.
 * Project:datacare-orm
 * Id: SQLResult.java   2020-09-29 22-53-22
 * Author: Evan
 */
package cn.datacare.orm.source;

import cn.datacare.orm.engine.SQLParameter;

import java.util.List;

/**
 * <p>
 * Title:
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Copyright: 2015~2020
 * </p>
 * <p>
 * Company/Department: xforceplus
 * </p>
 *
 * @author Evan
 * <b>Creation Time:</b> 2020-09-29 22-53-22
 * @since V1.0
 */
public class SQLResult {
    /**
     * jdbc 对应的sql
     */
    private String jdbcSql;
    /**
     * jdbc对应的参数，包含了值，可能的对应的表达式
     */
    private List<SQLParameter> jdbcParam;
    /**
     * 获取jdbc对应的参数
     * @return
     */
    public Object[] toObjectArray(){
        if(jdbcParam==null) {
            return new Object[0];
        }
        Object[] objs = new Object[jdbcParam.size()];
        int i =0;
        for(SQLParameter spa:jdbcParam){
            objs[i++] = spa.getValue();
        }
        return objs;

    }

    public String getJdbcSql() {
        return jdbcSql;
    }

    public void setJdbcSql(String jdbcSql) {
        this.jdbcSql = jdbcSql;
    }

    public List<SQLParameter> getJdbcParam() {
        return jdbcParam;
    }

    public void setJdbcParam(List<SQLParameter> jdbcParam) {
        this.jdbcParam = jdbcParam;
    }
}
